dnl -*- sh -*-
AC_INIT(src/slang.c)

# Installation location
AC_PREFIX_DEFAULT(/usr)
JD_INIT
JD_ANSI_CC

AC_CONFIG_AUX_DIR(autoconf)
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL

#Check these header since they cause trouble
AC_CHECK_HEADERS( \
stdlib.h \
unistd.h \
memory.h \
termios.h \
malloc.h \
fcntl.h \
sys/fcntl.h \
)

AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T

AC_CHECK_FUNCS(\
memset \
memcpy \
putenv \
getcwd \
tcgetattr \
tcsetattr \
cfgetospeed \
sigaction \
sigemptyset \
sigprocmask \
sigaddset \
vfscanf
)

JD_TERMCAP
JD_GCC_WARNINGS

JD_SET_OBJ_SRC_DIR(src)
JD_GET_MODULES(src/modules.unx)
JD_CREATE_MODULE_ORULES

AC_MSG_CHECKING(SLANG_VERSION)
slang_version=`grep "^#define  *SLANG_VERSION " $srcdir/src/slang.h |
               awk '{ print [$]3 }'`
slang_minor_version=`echo $slang_version | awk '{ print [$]1/100 }'`
slang_major_version=`echo $slang_version |
 awk '{ print [$]1 - 100 * '$slang_minor_version' }'`
AC_MSG_RESULT($slang_major_version.$slang_minor_version)
AC_SUBST(slang_major_version)
AC_SUBST(slang_minor_version)

AC_CONFIG_HEADER(src/sysconf.h:src/config.hin)

AC_CONFIG_SUBDIRS(demo)

AC_OUTPUT(Makefile:autoconf/Makefile.in src/Makefile)

JD_CREATE_EXEC_RULE(worm)
JD_CREATE_EXEC_RULE(calc)
JD_CREATE_EXEC_RULE(untic)
JD_APPEND_RULES(src/Makefile)
JD_APPEND_ELFRULES(src/Makefile)

echo ""
echo "Configuration complete.  You may need to edit src/Makefile."
echo "See also src/sl-feat.h for Kanji support."
echo "Type 'make' to build normal library."
echo "On Linux ELF systems, type 'make elf' to create ELF shared library."
